﻿
using System.Collections.Generic;
using System.Threading.Tasks;
namespace Reuse.PCL.Services {

	/// <summary>
	/// This service can help you use temporary and persistent storage, serializes objects to JSON strings and stores and retrieves in and from Application State and Isolated Storage
	/// </summary>
	public interface IStateService {


		/// <summary>
		/// Gets objects from temporary Application State or persistent Application Storage
		/// </summary>
		/// <typeparam name="T">Type of the object in the storage</typeparam>
		/// <param name="key">Key that identifies object</param>
		/// <param name="isPersistentStorage">True when retrieving from Application Storage in WP or AplicationData in WS, false when retrieving from Application State in WP or Session State in WS</param>
		/// <returns>The object retrieved from storage</returns>
		T GetState<T>( string key, bool isPersistentStorage = false );


		/// <summary>
		/// Stores object in temporary Application State or persistent Application Storage
		/// </summary>
		/// <param name="key">Key to identify the object</param>
		/// <param name="value">Object to store</param>
		/// <param name="isPersistentStorage">True when storing to Application Storage in WP or AplicationData in WS, false when storing to Application State in WP or Session State in WS</param>
		void SetState( string key, object value, bool isPersistentStorage = false );

		/// <summary>
		/// Windows 8 only, register the Aplication Frame for State restoring.
		/// </summary>
		/// <param name="frame">Application Frame to register</param>
		void RegisterAppFrame( object frame );

		/// <summary>
		/// Windows 8 only, restore state.
		/// </summary>
		Task RestoreState();

		/// <summary>
		/// Windows 8 only, save state.
		/// </summary>
		Task SaveState();

		/// <summary>
		/// Windows 8 only, restore frame state.
		/// </summary>
		Dictionary<string, object> SessionStateForFrame(object frame);
	}
}
